


import 'package:Flutter_Demo/core/model/category_model.dart';
import 'package:Flutter_Demo/ui/pages/meal/meal.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MYHomeCategoryItem extends StatelessWidget {

  final MYCategoryModel _categoryModel;

  MYHomeCategoryItem(this._categoryModel);

  @override
  Widget build(BuildContext context) {

    final bgColor = _categoryModel.cColor;

    return GestureDetector(
      child: Container(
        decoration: BoxDecoration(
            color: bgColor,
            borderRadius: BorderRadius.circular(12),
            // 渐变
            gradient: LinearGradient(
              colors: [
                bgColor.withOpacity(0.5),
                bgColor,
              ],
            )
        ),
        alignment: Alignment.center,
        child: Text(_categoryModel.title, style: Theme.of(context).textTheme.headline6,),
      ),
      onTap: () {
        Navigator.of(context).pushNamed(MYMealScreen.routeName, arguments: _categoryModel);
      },
    );
  }
}